package com.neuedu.my12306.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.neuedu.my12306.entity.UserInfo;
import com.neuedu.my12306.service.IUserInfoService;
import com.neuedu.my12306.util.SpringContextUtil;

/**
 * Servlet implementation class ToEditUserServlet
 */
@WebServlet("/ToEditUserServlet.do")
public class ToEditUserServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private IUserInfoService userInfoService;  
    public ToEditUserServlet() {
        super();
        //使用IUserInfoService接口解耦合 CheckUserNameServlet  与IUserInfoServiceImpl 的耦合关系
        // userInfoService = new IUserInfoServiceImpl();
         userInfoService = SpringContextUtil.getBean("userService", IUserInfoService.class);
       
    }


	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//1.在接收数据前进行编码转换(统一使用过滤器转换)
		String userName = request.getParameter("uname");
		UserInfo userInfo = userInfoService.findUserInfoByid(userName);
		
		request.setAttribute("user", userInfo);
		request.getRequestDispatcher("Admin/UserManageInfo_Amind_Edit.jsp").forward(request, response);
		
	}

}
